/*
 * sSight.h
 *
 *  Created on: 08.12.2010
 *      Author: 123
 */

#ifndef SSIGHT_H_
#define SSIGHT_H_
#include "Timer.h"
#include <oslib/oslib.h>
#include "Colors.h"
extern int CameraX;
extern int CameraY;

class sSight {
	int X;
	int Y;
	int DirLen;
	Timer * time;
	int spread;
	int MaxSpread;

public:

	sSight() {
		DirLen = 32;
		time = new Timer(0.1);
		time->startTimer();
		spread = 1;

	}
	~sSight() {
		delete (time);
	}
	void Draw(int x, int y, float ang) {
		if (spread > MaxSpread)
			spread = MaxSpread;
		if (time->getTimer() > 0.01 && spread > 0) {
			spread -= 1;
			time->resetTimer();
		}

		//X=Char[0].x-CameraX+DirLen*cos((Char[0].HeroTex->ty-spread)*3.14159265/180);

		//Y=Char[0].y-CameraY+DirLen*sin((Char[0].HeroTex->ty-spread)*3.14159265/180);
		X = x - CameraX + DirLen * cos((ang - spread) * 3.14159265 / 180);
		Y = y - CameraY + DirLen * sin((ang - spread) * 3.14159265 / 180);

		//oslDrawRect(X-5,Y-5,X+5,Y+5,RED);
		oslDrawLine(x - CameraX, y - CameraY, X, Y, RED);
		X = x - CameraX + DirLen * cos((ang + spread) * 3.14159265 / 180);
		Y = y - CameraY + DirLen * sin((ang + spread) * 3.14159265 / 180);
		//oslDrawRect(X-5,Y-5,X+5,Y+5,RED);
		oslDrawLine(x - CameraX, y - CameraY, X, Y, RED);

	}

	void SetSpread(int spread) {

		if (spread == -1) {
			this->spread = MaxSpread;
		} else
			this->spread = spread;

	}
	void SetMaxSpread(int MaxSpread) {
		this->MaxSpread = MaxSpread;
	}
	int GetSpread() {
		return spread;
	}
	int GetMaxSpread() {
		return MaxSpread;
	}

};
//extern sSight Sight;
#endif /* SSIGHT_H_ */
